home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / ExtUtils / MakeMaker.pm < prev    next >
Encoding:
Text File  |  1999-12-28  |  50.2 KB  |  1,716 lines

  1. BEGIN {require 5.002;} # MakeMaker 5.17 was the last MakeMaker that was compatible with perl5.001m
  2.  
  3. package ExtUtils::MakeMaker;
  4.  
  5. $Version = $VERSION = "5.42";
  6. $Version_OK = "5.17";    # Makefiles older than $Version_OK will die
  7. ($Revision = substr(q$Revision: 1.216 $, 10)) =~ s/\s+$//;
  8.  
  9.  
  10.  
  11. require Exporter;
  12. use Config;
  13. use Carp ();
  14.  
  15. use vars qw(
  16.  
  17.         @ISA @EXPORT @EXPORT_OK $AUTOLOAD
  18.         $ISA_TTY $Is_Mac $Is_OS2 $Is_VMS $Revision $Setup_done
  19.         $VERSION $Verbose $Version_OK %Config %Keep_after_flush
  20.         %MM_Sections %Prepend_dot_dot %Recognized_Att_Keys
  21.         @Get_from_Config @MM_Sections @Overridable @Parent
  22.  
  23.        );
  24.  
  25.  
  26. @ISA = qw(Exporter);
  27. @EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
  28. @EXPORT_OK = qw($VERSION &Version_check &neatvalue &mkbootstrap &mksymlists
  29.         $Version);
  30.  
  31. @MM::ISA = qw[ExtUtils::MM_Unix ExtUtils::Liblist ExtUtils::MakeMaker];
  32.  
  33. {
  34.     package MY;
  35.     @MY::ISA = qw(MM);
  36.     package MM;
  37.     sub DESTROY {}
  38. }
  39.  
  40. package ExtUtils::Liblist;
  41.  
  42. package ExtUtils::MakeMaker;
  43. $Is_VMS   = $^O eq 'VMS';
  44. $Is_OS2   = $^O eq 'os2';
  45. $Is_Mac   = $^O eq 'MacOS';
  46. $Is_Win32 = $^O eq 'MSWin32';
  47.  
  48. require ExtUtils::MM_Unix;
  49.  
  50. if ($Is_VMS) {
  51.     require ExtUtils::MM_VMS;
  52.     require VMS::Filespec; # is a noop as long as we require it within MM_VMS
  53. }
  54. if ($Is_OS2) {
  55.     require ExtUtils::MM_OS2;
  56. }
  57. if ($Is_Mac) {
  58.     require ExtUtils::MM_Mac;
  59. }
  60. if ($Is_Win32) {
  61.     require ExtUtils::MM_Win32;
  62. }
  63.  
  64.  
  65. sub AUTOLOAD {
  66.     my $code;
  67.     if (defined fileno(DATA)) {
  68.     my $fh = select DATA;
  69.     my $o = $/;            # For future reads from the file.
  70.     $/ = "\n__END__\n";
  71.     $code = <DATA>;
  72.     $/ = $o;
  73.     select $fh;
  74.     close DATA;
  75.     eval $code;
  76.     if ($@) {
  77.         $@ =~ s/ at .*\n//;
  78.         Carp::croak $@;
  79.     }
  80.     } else {
  81.     warn "AUTOLOAD called unexpectedly for $AUTOLOAD"; 
  82.     }
  83.     defined(&$AUTOLOAD) or die "Myloader inconsistency error";
  84.     goto &$AUTOLOAD;
  85. }
  86.  
  87.  
  88. sub Version_check {
  89.     my($checkversion) = @_;
  90.     die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
  91. Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable
  92. changes in the meantime.
  93. Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n"
  94.     if $checkversion < $Version_OK;
  95.     printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v",
  96.     $checkversion, "Current Version is", $VERSION
  97.     unless $checkversion == $VERSION;
  98. }
  99.  
  100. sub warnhandler {
  101.     $_[0] =~ /^Use of uninitialized value/ && return;
  102.     $_[0] =~ /used only once/ && return;
  103.     $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return;
  104.     warn @_;
  105. }
  106.  
  107. sub ExtUtils::MakeMaker::eval_in_subdirs ;
  108. sub ExtUtils::MakeMaker::eval_in_x ;
  109. sub ExtUtils::MakeMaker::full_setup ;
  110. sub ExtUtils::MakeMaker::writeMakefile ;
  111. sub ExtUtils::MakeMaker::new ;
  112. sub ExtUtils::MakeMaker::check_manifest ;
  113. sub ExtUtils::MakeMaker::parse_args ;
  114. sub ExtUtils::MakeMaker::check_hints ;
  115. sub ExtUtils::MakeMaker::mv_all_methods ;
  116. sub ExtUtils::MakeMaker::skipcheck ;
  117. sub ExtUtils::MakeMaker::flush ;
  118. sub ExtUtils::MakeMaker::mkbootstrap ;
  119. sub ExtUtils::MakeMaker::mksymlists ;
  120. sub ExtUtils::MakeMaker::neatvalue ;
  121. sub ExtUtils::MakeMaker::selfdocument ;
  122. sub ExtUtils::MakeMaker::WriteMakefile ;
  123. sub ExtUtils::MakeMaker::prompt ($;$) ;
  124.  
  125. 1;
  126.  
  127. __DATA__
  128.  
  129. package ExtUtils::MakeMaker;
  130.  
  131. sub WriteMakefile {
  132.     Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
  133.     local $SIG{__WARN__} = \&warnhandler;
  134.  
  135.     unless ($Setup_done++){
  136.     full_setup();
  137.     undef &ExtUtils::MakeMaker::full_setup; #safe memory
  138.     }
  139.     my %att = @_;
  140.     MM->new(\%att)->flush;
  141. }
  142.  
  143. sub prompt ($;$) {
  144.     my($mess,$def)=@_;
  145.     $ISA_TTY = -t STDIN && -t STDOUT ;
  146.     Carp::confess("prompt function called without an argument") unless defined $mess;
  147.     my $dispdef = defined $def ? "[$def] " : " ";
  148.     $def = defined $def ? $def : "";
  149.     my $ans;
  150.     if ($ISA_TTY) {
  151.     local $|=1;
  152.     print "$mess $dispdef";
  153.     chomp($ans = <STDIN>);
  154.     }
  155.     return $ans || $def;
  156. }
  157.  
  158. sub eval_in_subdirs {
  159.     my($self) = @_;
  160.     my($dir);
  161.     use Cwd 'cwd';
  162.     my $pwd = cwd();
  163.  
  164.     foreach $dir (@{$self->{DIR}}){
  165.     my($abs) = $self->catdir($pwd,$dir);
  166.     $self->eval_in_x($abs);
  167.     }
  168.     chdir $pwd;
  169. }
  170.  
  171. sub eval_in_x {
  172.     my($self,$dir) = @_;
  173.     package main;
  174.     chdir $dir or Carp::carp("Couldn't change to directory $dir: $!");
  175.     local *FH;
  176.     open(FH,"Makefile.PL") or Carp::carp("Couldn't open Makefile.PL in $dir");
  177.     my $eval = join "", <FH>;
  178.     close FH;
  179.     eval $eval;
  180.     if ($@) {
  181.     warn "WARNING from evaluation of $dir/Makefile.PL: $@";
  182.     }
  183. }
  184.  
  185. sub full_setup {
  186.     $Verbose ||= 0;
  187.     $^W=1;
  188.  
  189.     $PACKNAME = "PACK000";
  190.  
  191.     @Attrib_help = qw/
  192.  
  193.     C CCFLAGS CONFIG CONFIGURE DEFINE DIR DISTNAME DL_FUNCS DL_VARS
  194.     EXE_FILES EXCLUDE_EXT INCLUDE_EXT NO_VC FIRST_MAKEFILE FULLPERL H
  195.     INC INSTALLARCHLIB INSTALLBIN INSTALLDIRS INSTALLMAN1DIR
  196.     INSTALLMAN3DIR INSTALLPRIVLIB INSTALLSCRIPT INSTALLSITEARCH
  197.     INSTALLSITELIB INST_ARCHLIB INST_BIN INST_EXE INST_LIB
  198.     INST_MAN1DIR INST_MAN3DIR INST_SCRIPT LDFROM LIBPERL_A LIB LIBS
  199.     LINKTYPE MAKEAPERL MAKEFILE MAN1PODS MAN3PODS MAP_TARGET MYEXTLIB
  200.     NAME NEEDS_LINKING NOECHO NORECURS OBJECT OPTIMIZE PERL PERLMAINCC
  201.     PERL_ARCHLIB PERL_LIB PERL_SRC PL_FILES PM PMLIBDIRS PREFIX
  202.     PREREQ_PM SKIP TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG
  203.     XS_VERSION clean depend dist dynamic_lib linkext macro realclean
  204.     tool_autosplit
  205.  
  206.     IMPORTS
  207.  
  208.     installpm
  209.     /;
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.     @MM_Sections = 
  217.     qw(
  218.  
  219.  post_initialize const_config constants tool_autosplit tool_xsubpp
  220.  tools_other dist macro depend cflags const_loadlibs const_cccmd
  221.  post_constants
  222.  
  223.  pasthru
  224.  
  225.  c_o xs_c xs_o top_targets linkext dlsyms dynamic dynamic_bs
  226.  dynamic_lib static static_lib manifypods processPL installbin subdirs
  227.  clean realclean dist_basics dist_core dist_dir dist_test dist_ci
  228.  install force perldepend makefile staticmake test
  229.  
  230.       ); # loses section ordering
  231.  
  232.     @Overridable = @MM_Sections;
  233.     push @Overridable, qw[
  234.  
  235.  dir_target libscan makeaperl needs_linking subdir_x test_via_harness
  236.  test_via_script
  237.  
  238.              ];
  239.  
  240.     push @MM_Sections, qw[
  241.  
  242.  pm_to_blib selfdocument
  243.  
  244.              ];
  245.  
  246.     push @MM_Sections, "postamble";
  247.     push @Overridable, "postamble";
  248.  
  249.     @Recognized_Att_Keys{@MM_Sections} = (1) x @MM_Sections;
  250.  
  251.     @Get_from_Config = 
  252.     qw(
  253.        ar cc cccdlflags ccdlflags dlext dlsrc ld lddlflags ldflags libc
  254.        lib_ext obj_ext ranlib sitelibexp sitearchexp so exe_ext
  255.       );
  256.  
  257.     my $item;
  258.     foreach $item (@Attrib_help){
  259.     $Recognized_Att_Keys{$item} = 1;
  260.     }
  261.     foreach $item (@Get_from_Config) {
  262.     $Recognized_Att_Keys{uc $item} = $Config{$item};
  263.     print "Attribute '\U$item\E' => '$Config{$item}'\n"
  264.         if ($Verbose >= 2);
  265.     }
  266.  
  267.     %Prepend_dot_dot = 
  268.     qw(
  269.  
  270.        INST_BIN 1 INST_EXE 1 INST_LIB 1 INST_ARCHLIB 1 INST_SCRIPT
  271.        1 MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1 PERL_SRC 1
  272.        PERL 1 FULLPERL 1
  273.  
  274.       );
  275.  
  276.     my @keep = qw/
  277.     NEEDS_LINKING HAS_LINK_CODE
  278.     /;
  279.     @Keep_after_flush{@keep} = (1) x @keep;
  280. }
  281.  
  282. sub writeMakefile {
  283.     die <<END;
  284.  
  285. The extension you are trying to build apparently is rather old and
  286. most probably outdated. We detect that from the fact, that a
  287. subroutine "writeMakefile" is called, and this subroutine is not
  288. supported anymore since about October 1994.
  289.  
  290. Please contact the author or look into CPAN (details about CPAN can be
  291. found in the FAQ and at http:/www.perl.com) for a more recent version
  292. of the extension. If you're really desperate, you can try to change
  293. the subroutine name from writeMakefile to WriteMakefile and rerun
  294. 'perl Makefile.PL', but you're most probably left alone, when you do
  295. so.
  296.  
  297. The MakeMaker team
  298.  
  299. END
  300. }
  301.  
  302. sub ExtUtils::MakeMaker::new {
  303.     my($class,$self) = @_;
  304.     my($key);
  305.  
  306.     print STDOUT "MakeMaker (v$VERSION)\n" if $Verbose;
  307.     if (-f "MANIFEST" && ! -f "Makefile"){
  308.     check_manifest();
  309.     }
  310.  
  311.     $self = {} unless (defined $self);
  312.  
  313.     check_hints($self);
  314.  
  315.     my(%initial_att) = %$self; # record initial attributes
  316.  
  317.     my($prereq);
  318.     foreach $prereq (sort keys %{$self->{PREREQ_PM}}) {
  319.     my $eval = "use $prereq $self->{PREREQ_PM}->{$prereq}";
  320.     eval $eval;
  321.     if ($@){
  322.         warn "Warning: prerequisite $prereq $self->{PREREQ_PM}->{$prereq} not found";
  323.     } else {
  324.         delete $self->{PREREQ_PM}{$prereq};
  325.     }
  326.     }
  327.  
  328.     if (defined $self->{CONFIGURE}) {
  329.     if (ref $self->{CONFIGURE} eq 'CODE') {
  330.         $self = { %$self, %{&{$self->{CONFIGURE}}}};
  331.     } else {
  332.         Carp::croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
  333.     }
  334.     }
  335.  
  336.     if ( Carp::longmess("") =~ /runsubdirpl/s ){
  337.     Carp::carp("WARNING: Please rerun 'perl Makefile.PL' to regenerate your Makefiles\n");
  338.     }
  339.  
  340.     my $newclass = ++$PACKNAME;
  341.     {
  342.     print "Blessing Object into class [$newclass]\n" if $Verbose>=2;
  343.     mv_all_methods("MY",$newclass);
  344.     bless $self, $newclass;
  345.     push @Parent, $self;
  346.     @{"$newclass\:\:ISA"} = 'MM';
  347.     }
  348.  
  349.     if (defined $Parent[-2]){
  350.     $self->{PARENT} = $Parent[-2];
  351.     my $key;
  352.     for $key (keys %Prepend_dot_dot) {
  353.         next unless defined $self->{PARENT}{$key};
  354.         $self->{$key} = $self->{PARENT}{$key};
  355.         $self->{$key} = $self->catdir("..",$self->{$key})
  356.         unless $self->file_name_is_absolute($self->{$key})
  357.         || ($^O eq 'VMS' and ($key =~ /PERL$/ && $self->{$key} =~ /^[\w\-\$]+$/));
  358.     }
  359.     $self->{PARENT}->{CHILDREN}->{$newclass} = $self if $self->{PARENT};
  360.     } else {
  361.     parse_args($self,@ARGV);
  362.     }
  363.  
  364.     $self->{NAME} ||= $self->guess_name;
  365.  
  366.     ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;
  367.  
  368.     $self->init_main();
  369.  
  370.     if (! $self->{PERL_SRC} ) {
  371.     my($pthinks) = $self->canonpath($INC{'Config.pm'});
  372.     my($cthinks) = $self->catfile($Config{'archlibexp'},'Config.pm');
  373.     $pthinks = VMS::Filespec::vmsify($pthinks) if $Is_VMS;
  374.     if ($pthinks ne $cthinks &&
  375.         !($Is_Win32 and lc($pthinks) eq lc($cthinks))) {
  376.             print "Have $pthinks expected $cthinks\n";
  377.         if ($Is_Win32) {
  378.         $pthinks =~ s![/\\]Config\.pm$!!i; $pthinks =~ s!.*[/\\]!!;
  379.         }
  380.         else {
  381.         $pthinks =~ s!/Config\.pm$!!; $pthinks =~ s!.*/!!;
  382.         }
  383.         print STDOUT <<END;
  384. Your perl and your Config.pm seem to have different ideas about the architecture
  385. they are running on.
  386. Perl thinks: [$pthinks]
  387. Config says: [$Config{archname}]
  388. This may or may not cause problems. Please check your installation of perl if you
  389. have problems building this extension.
  390. END
  391.     }
  392.     }
  393.  
  394.     $self->init_dirscan();
  395.     $self->init_others();
  396.  
  397.     push @{$self->{RESULT}}, <<END;
  398. END
  399.  
  400.     foreach $key (sort keys %initial_att){
  401.     my($v) = neatvalue($initial_att{$key});
  402.     $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
  403.     $v =~ tr/\n/ /s;
  404.     push @{$self->{RESULT}}, "#    $key => $v";
  405.     }
  406.  
  407.     my (%skip,$skip);
  408.     for $skip (@{$self->{SKIP} || []}) {
  409.     $self->{SKIPHASH}{$skip} = 1;
  410.     }
  411.     delete $self->{SKIP}; # free memory
  412.  
  413.     if ($self->{PARENT}) {
  414.     for (qw/install dist dist_basics dist_core dist_dir dist_test dist_ci/) {
  415.         $self->{SKIPHASH}{$_} = 1;
  416.     }
  417.     }
  418.  
  419.     unless ($self->{NORECURS}) {
  420.     $self->eval_in_subdirs if @{$self->{DIR}};
  421.     }
  422.  
  423.     my $section;
  424.     foreach $section ( @MM_Sections ){
  425.     print "Processing Makefile '$section' section\n" if ($Verbose >= 2);
  426.     my($skipit) = $self->skipcheck($section);
  427.     if ($skipit){
  428.         push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit.";
  429.     } else {
  430.         my(%a) = %{$self->{$section} || {}};
  431.         push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
  432.         push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a;
  433.         push @{$self->{RESULT}}, $self->nicetext($self->$section( %a ));
  434.     }
  435.     }
  436.  
  437.     push @{$self->{RESULT}}, "\n# End.";
  438.     pop @Parent;
  439.  
  440.     $self;
  441. }
  442.  
  443. sub check_manifest {
  444.     print STDOUT "Checking if your kit is complete...\n";
  445.     require ExtUtils::Manifest;
  446.     $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning
  447.     my(@missed)=ExtUtils::Manifest::manicheck();
  448.     if (@missed){
  449.     print STDOUT "Warning: the following files are missing in your kit:\n";
  450.     print "\t", join "\n\t", @missed;
  451.     print STDOUT "\n";
  452.     print STDOUT "Please inform the author.\n";
  453.     } else {
  454.     print STDOUT "Looks good\n";
  455.     }
  456. }
  457.  
  458. sub parse_args{
  459.     my($self, @args) = @_;
  460.     foreach (@args){
  461.     unless (m/(.*?)=(.*)/){
  462.         help(),exit 1 if m/^help$/;
  463.         ++$Verbose if m/^verb/;
  464.         next;
  465.     }
  466.     my($name, $value) = ($1, $2);
  467.     if ($value =~ m/^~(\w+)?/){ # tilde with optional username
  468.         $value =~ s [^~(\w*)]
  469.         [$1 ?
  470.          ((getpwnam($1))[7] || "~$1") :
  471.          (getpwuid($>))[7]
  472.          ]ex;
  473.     }
  474.     $self->{uc($name)} = $value;
  475.     }
  476.  
  477.     if (defined $self->{potential_libs}){
  478.     my($msg)="'potential_libs' => '$self->{potential_libs}' should be";
  479.     if ($self->{potential_libs}){
  480.         print STDOUT "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n";
  481.     } else {
  482.         print STDOUT "$msg deleted.\n";
  483.     }
  484.     $self->{LIBS} = [$self->{potential_libs}];
  485.     delete $self->{potential_libs};
  486.     }
  487.     if (defined $self->{ARMAYBE}){
  488.     my($armaybe) = $self->{ARMAYBE};
  489.     print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
  490.             "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
  491.     my(%dl) = %{$self->{dynamic_lib} || {}};
  492.     $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe};
  493.     delete $self->{ARMAYBE};
  494.     }
  495.     if (defined $self->{LDTARGET}){
  496.     print STDOUT "LDTARGET should be changed to LDFROM\n";
  497.     $self->{LDFROM} = $self->{LDTARGET};
  498.     delete $self->{LDTARGET};
  499.     }
  500.     if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') {
  501.     $self->{DIR} = [grep $_, split ":", $self->{DIR}];
  502.     }
  503.     if (defined $self->{INCLUDE_EXT} && ref \$self->{INCLUDE_EXT} eq 'SCALAR') {
  504.     $self->{INCLUDE_EXT} = [grep $_, split '\s+', $self->{INCLUDE_EXT}];
  505.     }
  506.     if (defined $self->{EXCLUDE_EXT} && ref \$self->{EXCLUDE_EXT} eq 'SCALAR') {
  507.     $self->{EXCLUDE_EXT} = [grep $_, split '\s+', $self->{EXCLUDE_EXT}];
  508.     }
  509.     my $mmkey;
  510.     foreach $mmkey (sort keys %$self){
  511.     print STDOUT "    $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $Verbose;
  512.     print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n"
  513.         unless exists $Recognized_Att_Keys{$mmkey};
  514.     }
  515.     $| = 1 if $Verbose;
  516. }
  517.  
  518. sub check_hints {
  519.     my($self) = @_;
  520.  
  521.     return unless -d "hints";
  522.  
  523.     my(@goodhints);
  524.     my($hint)="${^O}_$Config{osvers}";
  525.     $hint =~ s/\./_/g;
  526.     $hint =~ s/_$//;
  527.     return unless $hint;
  528.  
  529.     while (1) {
  530.     last if -f "hints/$hint.pl";      # found
  531.     } continue {
  532.     last unless $hint =~ s/_[^_]*$//; # nothing to cut off
  533.     }
  534.     return unless -f "hints/$hint.pl";    # really there
  535.  
  536.     local *FH;
  537.     open(FH,"hints/$hint.pl");
  538.     @goodhints = <FH>;
  539.     close FH;
  540.     print STDOUT "Processing hints file hints/$hint.pl\n";
  541.     eval join('',@goodhints);
  542.     print STDOUT $@ if $@;
  543. }
  544.  
  545. sub mv_all_methods {
  546.     my($from,$to) = @_;
  547.     my($method);
  548.     my($symtab) = \%{"${from}::"};
  549.  
  550.  
  551.     foreach $method (@Overridable) {
  552.  
  553.  
  554.  
  555.     next unless defined &{"${from}::$method"};
  556.  
  557.     *{"${to}::$method"} = \&{"${from}::$method"};
  558.  
  559.     
  560.     
  561.  
  562.     eval "package MY; sub $method { shift->SUPER::$method(\@_); }";
  563.     }
  564.  
  565.  
  566.  
  567. }
  568.  
  569. sub skipcheck {
  570.     my($self) = shift;
  571.     my($section) = @_;
  572.     if ($section eq 'dynamic') {
  573.     print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
  574.     "in skipped section 'dynamic_bs'\n"
  575.             if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
  576.         print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
  577.     "in skipped section 'dynamic_lib'\n"
  578.             if $self->{SKIPHASH}{dynamic_lib} && $Verbose;
  579.     }
  580.     if ($section eq 'dynamic_lib') {
  581.         print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ",
  582.     "targets in skipped section 'dynamic_bs'\n"
  583.             if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
  584.     }
  585.     if ($section eq 'static') {
  586.         print STDOUT "Warning (non-fatal): Target 'static' depends on targets ",
  587.     "in skipped section 'static_lib'\n"
  588.             if $self->{SKIPHASH}{static_lib} && $Verbose;
  589.     }
  590.     return 'skipped' if $self->{SKIPHASH}{$section};
  591.     return '';
  592. }
  593.  
  594. sub flush {
  595.     my $self = shift;
  596.     my($chunk);
  597.     local *FH;
  598.     print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n";
  599.  
  600.     unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
  601.     open(FH,">MakeMaker.tmp") or die "Unable to open MakeMaker.tmp: $!";
  602.  
  603.     for $chunk (@{$self->{RESULT}}) {
  604.     print FH "$chunk\n";
  605.     }
  606.  
  607.     close FH;
  608.     my($finalname) = $self->{MAKEFILE};
  609.     rename("MakeMaker.tmp", $finalname);
  610.     chmod 0644, $finalname unless $Is_VMS;
  611.  
  612.     if ($self->{PARENT}) {
  613.     foreach (keys %$self) { # safe memory
  614.         delete $self->{$_} unless $Keep_after_flush{$_};
  615.     }
  616.     }
  617.  
  618.     system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":";
  619. }
  620.  
  621. sub mkbootstrap {
  622.     die <<END;
  623. !!! Your Makefile has been built such a long time ago, !!!
  624. !!! that is unlikely to work with current MakeMaker.   !!!
  625. !!! Please rebuild your Makefile                       !!!
  626. END
  627. }
  628.  
  629. sub mksymlists {
  630.     die <<END;
  631. !!! Your Makefile has been built such a long time ago, !!!
  632. !!! that is unlikely to work with current MakeMaker.   !!!
  633. !!! Please rebuild your Makefile                       !!!
  634. END
  635. }
  636.  
  637. sub neatvalue {
  638.     my($v) = @_;
  639.     return "undef" unless defined $v;
  640.     my($t) = ref $v;
  641.     return "q[$v]" unless $t;
  642.     if ($t eq 'ARRAY') {
  643.     my(@m, $elem, @neat);
  644.     push @m, "[";
  645.     foreach $elem (@$v) {
  646.         push @neat, "q[$elem]";
  647.     }
  648.     push @m, join ", ", @neat;
  649.     push @m, "]";
  650.     return join "", @m;
  651.     }
  652.     return "$v" unless $t eq 'HASH';
  653.     my(@m, $key, $val);
  654.     while (($key,$val) = each %$v){
  655.     last unless defined $key; # cautious programming in case (undef,undef) is true
  656.     push(@m,"$key=>".neatvalue($val)) ;
  657.     }
  658.     return "{ ".join(', ',@m)." }";
  659. }
  660.  
  661. sub selfdocument {
  662.     my($self) = @_;
  663.     my(@m);
  664.     if ($Verbose){
  665.     push @m, "\n# Full list of MakeMaker attribute values:";
  666.     foreach $key (sort keys %$self){
  667.         next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/;
  668.         my($v) = neatvalue($self->{$key});
  669.         $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
  670.         $v =~ tr/\n/ /s;
  671.         push @m, "#    $key => $v";
  672.     }
  673.     }
  674.     join "\n", @m;
  675. }
  676.  
  677. package ExtUtils::MakeMaker;
  678. 1;
  679.  
  680. __END__
  681.  
  682. =head1 NAME
  683.  
  684. ExtUtils::MakeMaker - create an extension Makefile
  685.  
  686. =head1 SYNOPSIS
  687.  
  688. C<use ExtUtils::MakeMaker;>
  689.  
  690. C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );>
  691.  
  692. which is really
  693.  
  694. C<MM-E<gt>new(\%att)-E<gt>flush;>
  695.  
  696. =head1 DESCRIPTION
  697.  
  698. This utility is designed to write a Makefile for an extension module
  699. from a Makefile.PL. It is based on the Makefile.SH model provided by
  700. Andy Dougherty and the perl5-porters.
  701.  
  702. It splits the task of generating the Makefile into several subroutines
  703. that can be individually overridden.  Each subroutine returns the text
  704. it wishes to have written to the Makefile.
  705.  
  706. MakeMaker is object oriented. Each directory below the current
  707. directory that contains a Makefile.PL. Is treated as a separate
  708. object. This makes it possible to write an unlimited number of
  709. Makefiles with a single invocation of WriteMakefile().
  710.  
  711. =head2 How To Write A Makefile.PL
  712.  
  713. The short answer is: Don't.
  714.  
  715.         Always begin with h2xs.
  716.         Always begin with h2xs!
  717.         ALWAYS BEGIN WITH H2XS!
  718.  
  719. even if you're not building around a header file, and even if you
  720. don't have an XS component.
  721.  
  722. Run h2xs(1) before you start thinking about writing a module. For so
  723. called pm-only modules that consist of C<*.pm> files only, h2xs has
  724. the C<-X> switch. This will generate dummy files of all kinds that are
  725. useful for the module developer.
  726.  
  727. The medium answer is:
  728.  
  729.     use ExtUtils::MakeMaker;
  730.     WriteMakefile( NAME => "Foo::Bar" );
  731.  
  732. The long answer is the rest of the manpage :-)
  733.  
  734. =head2 Default Makefile Behaviour
  735.  
  736. The generated Makefile enables the user of the extension to invoke
  737.  
  738.   perl Makefile.PL # optionally "perl Makefile.PL verbose"
  739.   make
  740.   make test        # optionally set TEST_VERBOSE=1
  741.   make install     # See below
  742.  
  743. The Makefile to be produced may be altered by adding arguments of the
  744. form C<KEY=VALUE>. E.g.
  745.  
  746.   perl Makefile.PL PREFIX=/tmp/myperl5
  747.  
  748. Other interesting targets in the generated Makefile are
  749.  
  750.   make config     # to check if the Makefile is up-to-date
  751.   make clean      # delete local temp files (Makefile gets renamed)
  752.   make realclean  # delete derived files (including ./blib)
  753.   make ci         # check in all the files in the MANIFEST file
  754.   make dist       # see below the Distribution Support section
  755.  
  756. =head2 make test
  757.  
  758. MakeMaker checks for the existence of a file named F<test.pl> in the
  759. current directory and if it exists it adds commands to the test target
  760. of the generated Makefile that will execute the script with the proper
  761. set of perl C<-I> options.
  762.  
  763. MakeMaker also checks for any files matching glob("t/*.t"). It will
  764. add commands to the test target of the generated Makefile that execute
  765. all matching files via the L<Test::Harness> module with the C<-I>
  766. switches set correctly.
  767.  
  768. =head2 make testdb
  769.  
  770. A useful variation of the above is the target C<testdb>. It runs the
  771. test under the Perl debugger (see L<perldebug>). If the file
  772. F<test.pl> exists in the current directory, it is used for the test.
  773.  
  774. If you want to debug some other testfile, set C<TEST_FILE> variable
  775. thusly:
  776.  
  777.   make testdb TEST_FILE=t/mytest.t
  778.  
  779. By default the debugger is called using C<-d> option to perl. If you
  780. want to specify some other option, set C<TESTDB_SW> variable:
  781.  
  782.   make testdb TESTDB_SW=-Dx
  783.  
  784. =head2 make install
  785.  
  786. make alone puts all relevant files into directories that are named by
  787. the macros INST_LIB, INST_ARCHLIB, INST_SCRIPT, INST_MAN1DIR, and
  788. INST_MAN3DIR. All these default to something below ./blib if you are
  789. I<not> building below the perl source directory. If you I<are>
  790. building below the perl source, INST_LIB and INST_ARCHLIB default to
  791.  ../../lib, and INST_SCRIPT is not defined.
  792.  
  793. The I<install> target of the generated Makefile copies the files found
  794. below each of the INST_* directories to their INSTALL*
  795. counterparts. Which counterparts are chosen depends on the setting of
  796. INSTALLDIRS according to the following table:
  797.  
  798.                       INSTALLDIRS set to
  799.                               perl                 site
  800.  
  801.     INST_ARCHLIB    INSTALLARCHLIB    INSTALLSITEARCH
  802.     INST_LIB        INSTALLPRIVLIB    INSTALLSITELIB
  803.     INST_BIN                  INSTALLBIN
  804.     INST_SCRIPT              INSTALLSCRIPT
  805.     INST_MAN1DIR             INSTALLMAN1DIR
  806.     INST_MAN3DIR             INSTALLMAN3DIR
  807.  
  808. The INSTALL... macros in turn default to their %Config
  809. ($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts.
  810.  
  811. You can check the values of these variables on your system with
  812.  
  813.     perl '-V:install.*'
  814.  
  815. And to check the sequence in which the library directories are
  816. searched by perl, run
  817.  
  818.     perl -le 'print join $/, @INC'
  819.  
  820.  
  821. =head2 PREFIX and LIB attribute
  822.  
  823. PREFIX and LIB can be used to set several INSTALL* attributes in one
  824. go. The quickest way to install a module in a non-standard place might
  825. be
  826.  
  827.     perl Makefile.PL LIB=~/lib
  828.  
  829. This will install the module's architecture-independent files into
  830. ~/lib, the architecture-dependent files into ~/lib/$archname/auto.
  831.  
  832. Another way to specify many INSTALL directories with a single
  833. parameter is PREFIX.
  834.  
  835.     perl Makefile.PL PREFIX=~
  836.  
  837. This will replace the string specified by $Config{prefix} in all
  838. $Config{install*} values.
  839.  
  840. Note, that in both cases the tilde expansion is done by MakeMaker, not
  841. by perl by default, nor by make. Conflicts between parmeters LIB,
  842. PREFIX and the various INSTALL* arguments are resolved so that 
  843. XXX
  844.  
  845. If the user has superuser privileges, and is not working on AFS
  846. (Andrew File System) or relatives, then the defaults for
  847. INSTALLPRIVLIB, INSTALLARCHLIB, INSTALLSCRIPT, etc. will be appropriate,
  848. and this incantation will be the best:
  849.  
  850.     perl Makefile.PL; make; make test
  851.     make install
  852.  
  853. make install per default writes some documentation of what has been
  854. done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This feature
  855. can be bypassed by calling make pure_install.
  856.  
  857. =head2 AFS users
  858.  
  859. will have to specify the installation directories as these most
  860. probably have changed since perl itself has been installed. They will
  861. have to do this by calling
  862.  
  863.     perl Makefile.PL INSTALLSITELIB=/afs/here/today \
  864.     INSTALLSCRIPT=/afs/there/now INSTALLMAN3DIR=/afs/for/manpages
  865.     make
  866.  
  867. Be careful to repeat this procedure every time you recompile an
  868. extension, unless you are sure the AFS installation directories are
  869. still valid.
  870.  
  871. =head2 Static Linking of a new Perl Binary
  872.  
  873. An extension that is built with the above steps is ready to use on
  874. systems supporting dynamic loading. On systems that do not support
  875. dynamic loading, any newly created extension has to be linked together
  876. with the available resources. MakeMaker supports the linking process
  877. by creating appropriate targets in the Makefile whenever an extension
  878. is built. You can invoke the corresponding section of the makefile with
  879.  
  880.     make perl
  881.  
  882. That produces a new perl binary in the current directory with all
  883. extensions linked in that can be found in INST_ARCHLIB , SITELIBEXP,
  884. and PERL_ARCHLIB. To do that, MakeMaker writes a new Makefile, on
  885. UNIX, this is called Makefile.aperl (may be system dependent). If you
  886. want to force the creation of a new perl, it is recommended, that you
  887. delete this Makefile.aperl, so the directories are searched-through
  888. for linkable libraries again.
  889.  
  890. The binary can be installed into the directory where perl normally
  891. resides on your machine with
  892.  
  893.     make inst_perl
  894.  
  895. To produce a perl binary with a different name than C<perl>, either say
  896.  
  897.     perl Makefile.PL MAP_TARGET=myperl
  898.     make myperl
  899.     make inst_perl
  900.  
  901. or say
  902.  
  903.     perl Makefile.PL
  904.     make myperl MAP_TARGET=myperl
  905.     make inst_perl MAP_TARGET=myperl
  906.  
  907. In any case you will be prompted with the correct invocation of the
  908. C<inst_perl> target that installs the new binary into INSTALLBIN.
  909.  
  910. make inst_perl per default writes some documentation of what has been
  911. done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This
  912. can be bypassed by calling make pure_inst_perl.
  913.  
  914. Warning: the inst_perl: target will most probably overwrite your
  915. existing perl binary. Use with care!
  916.  
  917. Sometimes you might want to build a statically linked perl although
  918. your system supports dynamic loading. In this case you may explicitly
  919. set the linktype with the invocation of the Makefile.PL or make:
  920.  
  921.     perl Makefile.PL LINKTYPE=static    # recommended
  922.  
  923. or
  924.  
  925.     make LINKTYPE=static                # works on most systems
  926.  
  927. =head2 Determination of Perl Library and Installation Locations
  928.  
  929. MakeMaker needs to know, or to guess, where certain things are
  930. located.  Especially INST_LIB and INST_ARCHLIB (where to put the files
  931. during the make(1) run), PERL_LIB and PERL_ARCHLIB (where to read
  932. existing modules from), and PERL_INC (header files and C<libperl*.*>).
  933.  
  934. Extensions may be built either using the contents of the perl source
  935. directory tree or from the installed perl library. The recommended way
  936. is to build extensions after you have run 'make install' on perl
  937. itself. You can do that in any directory on your hard disk that is not
  938. below the perl source tree. The support for extensions below the ext
  939. directory of the perl distribution is only good for the standard
  940. extensions that come with perl.
  941.  
  942. If an extension is being built below the C<ext/> directory of the perl
  943. source then MakeMaker will set PERL_SRC automatically (e.g.,
  944. C<../..>).  If PERL_SRC is defined and the extension is recognized as
  945. a standard extension, then other variables default to the following:
  946.  
  947.   PERL_INC     = PERL_SRC
  948.   PERL_LIB     = PERL_SRC/lib
  949.   PERL_ARCHLIB = PERL_SRC/lib
  950.   INST_LIB     = PERL_LIB
  951.   INST_ARCHLIB = PERL_ARCHLIB
  952.  
  953. If an extension is being built away from the perl source then MakeMaker
  954. will leave PERL_SRC undefined and default to using the installed copy
  955. of the perl library. The other variables default to the following:
  956.  
  957.   PERL_INC     = $archlibexp/CORE
  958.   PERL_LIB     = $privlibexp
  959.   PERL_ARCHLIB = $archlibexp
  960.   INST_LIB     = ./blib/lib
  961.   INST_ARCHLIB = ./blib/arch
  962.  
  963. If perl has not yet been installed then PERL_SRC can be defined on the
  964. command line as shown in the previous section.
  965.  
  966.  
  967. =head2 Which architecture dependent directory?
  968.  
  969. If you don't want to keep the defaults for the INSTALL* macros,
  970. MakeMaker helps you to minimize the typing needed: the usual
  971. relationship between INSTALLPRIVLIB and INSTALLARCHLIB is determined
  972. by Configure at perl compilation time. MakeMaker supports the user who
  973. sets INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not,
  974. then MakeMaker defaults the latter to be the same subdirectory of
  975. INSTALLPRIVLIB as Configure decided for the counterparts in %Config ,
  976. otherwise it defaults to INSTALLPRIVLIB. The same relationship holds
  977. for INSTALLSITELIB and INSTALLSITEARCH.
  978.  
  979. MakeMaker gives you much more freedom than needed to configure
  980. internal variables and get different results. It is worth to mention,
  981. that make(1) also lets you configure most of the variables that are
  982. used in the Makefile. But in the majority of situations this will not
  983. be necessary, and should only be done, if the author of a package
  984. recommends it (or you know what you're doing).
  985.  
  986. =head2 Using Attributes and Parameters
  987.  
  988. The following attributes can be specified as arguments to WriteMakefile()
  989. or as NAME=VALUE pairs on the command line:
  990.  
  991. =cut
  992.  
  993.  
  994. =over 2
  995.  
  996. =item C
  997.  
  998. Ref to array of *.c file names. Initialised from a directory scan
  999. and the values portion of the XS attribute hash. This is not
  1000. currently used by MakeMaker but may be handy in Makefile.PLs.
  1001.  
  1002. =item CCFLAGS
  1003.  
  1004. String that will be included in the compiler call command line between
  1005. the arguments INC and OPTIMIZE.
  1006.  
  1007. =item CONFIG
  1008.  
  1009. Arrayref. E.g. [qw(archname manext)] defines ARCHNAME & MANEXT from
  1010. config.sh. MakeMaker will add to CONFIG the following values anyway:
  1011. ar
  1012. cc
  1013. cccdlflags
  1014. ccdlflags
  1015. dlext
  1016. dlsrc
  1017. ld
  1018. lddlflags
  1019. ldflags
  1020. libc
  1021. lib_ext
  1022. obj_ext
  1023. ranlib
  1024. sitelibexp
  1025. sitearchexp
  1026. so
  1027.  
  1028. =item CONFIGURE
  1029.  
  1030. CODE reference. The subroutine should return a hash reference. The
  1031. hash may contain further attributes, e.g. {LIBS =E<gt> ...}, that have to
  1032. be determined by some evaluation method.
  1033.  
  1034. =item DEFINE
  1035.  
  1036. Something like C<"-DHAVE_UNISTD_H">
  1037.  
  1038. =item DIR
  1039.  
  1040. Ref to array of subdirectories containing Makefile.PLs e.g. [ 'sdbm'
  1041. ] in ext/SDBM_File
  1042.  
  1043. =item DISTNAME
  1044.  
  1045. Your name for distributing the package (by tar file). This defaults to
  1046. NAME above.
  1047.  
  1048. =item DL_FUNCS
  1049.  
  1050. Hashref of symbol names for routines to be made available as
  1051. universal symbols.  Each key/value pair consists of the package name
  1052. and an array of routine names in that package.  Used only under AIX
  1053. (export lists) and VMS (linker options) at present.  The routine
  1054. names supplied will be expanded in the same way as XSUB names are
  1055. expanded by the XS() macro.  Defaults to
  1056.  
  1057.   {"$(NAME)" => ["boot_$(NAME)" ] }
  1058.  
  1059. e.g.
  1060.  
  1061.   {"RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
  1062.    "NetconfigPtr" => [ 'DESTROY'] }
  1063.  
  1064. =item DL_VARS
  1065.  
  1066. Array of symbol names for variables to be made available as
  1067. universal symbols.  Used only under AIX (export lists) and VMS
  1068. (linker options) at present.  Defaults to [].  (e.g. [ qw(
  1069. Foo_version Foo_numstreams Foo_tree ) ])
  1070.  
  1071. =item EXCLUDE_EXT
  1072.  
  1073. Array of extension names to exclude when doing a static build.  This
  1074. is ignored if INCLUDE_EXT is present.  Consult INCLUDE_EXT for more
  1075. details.  (e.g.  [ qw( Socket POSIX ) ] )
  1076.  
  1077. This attribute may be most useful when specified as a string on the
  1078. commandline:  perl Makefile.PL EXCLUDE_EXT='Socket Safe'
  1079.  
  1080. =item EXE_FILES
  1081.  
  1082. Ref to array of executable files. The files will be copied to the
  1083. INST_SCRIPT directory. Make realclean will delete them from there
  1084. again.
  1085.  
  1086. =item NO_VC
  1087.  
  1088. In general any generated Makefile checks for the current version of
  1089. MakeMaker and the version the Makefile was built under. If NO_VC is
  1090. set, the version check is neglected. Do not write this into your
  1091. Makefile.PL, use it interactively instead.
  1092.  
  1093. =item FIRST_MAKEFILE
  1094.  
  1095. The name of the Makefile to be produced. Defaults to the contents of
  1096. MAKEFILE, but can be overridden. This is used for the second Makefile
  1097. that will be produced for the MAP_TARGET.
  1098.  
  1099. =item FULLPERL
  1100.  
  1101. Perl binary able to run this extension.
  1102.  
  1103. =item H
  1104.  
  1105. Ref to array of *.h file names. Similar to C.
  1106.  
  1107. =item IMPORTS
  1108.  
  1109. IMPORTS is only used on OS/2.
  1110.  
  1111. =item INC
  1112.  
  1113. Include file dirs eg: C<"-I/usr/5include -I/path/to/inc">
  1114.  
  1115. =item INCLUDE_EXT
  1116.  
  1117. Array of extension names to be included when doing a static build.
  1118. MakeMaker will normally build with all of the installed extensions when
  1119. doing a static build, and that is usually the desired behavior.  If
  1120. INCLUDE_EXT is present then MakeMaker will build only with those extensions
  1121. which are explicitly mentioned. (e.g.  [ qw( Socket POSIX ) ])
  1122.  
  1123. It is not necessary to mention DynaLoader or the current extension when
  1124. filling in INCLUDE_EXT.  If the INCLUDE_EXT is mentioned but is empty then
  1125. only DynaLoader and the current extension will be included in the build.
  1126.  
  1127. This attribute may be most useful when specified as a string on the
  1128. commandline:  perl Makefile.PL INCLUDE_EXT='POSIX Socket Devel::Peek'
  1129.  
  1130. =item INSTALLARCHLIB
  1131.  
  1132. Used by 'make install', which copies files from INST_ARCHLIB to this
  1133. directory if INSTALLDIRS is set to perl.
  1134.  
  1135. =item INSTALLBIN
  1136.  
  1137. Directory to install binary files (e.g. tkperl) into.
  1138.  
  1139. =item INSTALLDIRS
  1140.  
  1141. Determines which of the two sets of installation directories to
  1142. choose: installprivlib and installarchlib versus installsitelib and
  1143. installsitearch. The first pair is chosen with INSTALLDIRS=perl, the
  1144. second with INSTALLDIRS=site. Default is site.
  1145.  
  1146. =item INSTALLMAN1DIR
  1147.  
  1148. This directory gets the man pages at 'make install' time. Defaults to
  1149. $Config{installman1dir}.
  1150.  
  1151. =item INSTALLMAN3DIR
  1152.  
  1153. This directory gets the man pages at 'make install' time. Defaults to
  1154. $Config{installman3dir}.
  1155.  
  1156. =item INSTALLPRIVLIB
  1157.  
  1158. Used by 'make install', which copies files from INST_LIB to this
  1159. directory if INSTALLDIRS is set to perl.
  1160.  
  1161. =item INSTALLSCRIPT
  1162.  
  1163. Used by 'make install' which copies files from INST_SCRIPT to this
  1164. directory.
  1165.  
  1166. =item INSTALLSITELIB
  1167.  
  1168. Used by 'make install', which copies files from INST_LIB to this
  1169. directory if INSTALLDIRS is set to site (default).
  1170.  
  1171. =item INSTALLSITEARCH
  1172.  
  1173. Used by 'make install', which copies files from INST_ARCHLIB to this
  1174. directory if INSTALLDIRS is set to site (default).
  1175.  
  1176. =item INST_ARCHLIB
  1177.  
  1178. Same as INST_LIB for architecture dependent files.
  1179.  
  1180. =item INST_BIN
  1181.  
  1182. Directory to put real binary files during 'make'. These will be copied
  1183. to INSTALLBIN during 'make install'
  1184.  
  1185. =item INST_EXE
  1186.  
  1187. Old name for INST_SCRIPT. Deprecated. Please use INST_SCRIPT if you
  1188. need to use it.
  1189.  
  1190. =item INST_LIB
  1191.  
  1192. Directory where we put library files of this extension while building
  1193. it.
  1194.  
  1195. =item INST_MAN1DIR
  1196.  
  1197. Directory to hold the man pages at 'make' time
  1198.  
  1199. =item INST_MAN3DIR
  1200.  
  1201. Directory to hold the man pages at 'make' time
  1202.  
  1203. =item INST_SCRIPT
  1204.  
  1205. Directory, where executable files should be installed during
  1206. 'make'. Defaults to "./blib/bin", just to have a dummy location during
  1207. testing. make install will copy the files in INST_SCRIPT to
  1208. INSTALLSCRIPT.
  1209.  
  1210. =item LDFROM
  1211.  
  1212. defaults to "$(OBJECT)" and is used in the ld command to specify
  1213. what files to link/load from (also see dynamic_lib below for how to
  1214. specify ld flags)
  1215.  
  1216. =item LIBPERL_A
  1217.  
  1218. The filename of the perllibrary that will be used together with this
  1219. extension. Defaults to libperl.a.
  1220.  
  1221. =item LIB
  1222.  
  1223. LIB can only be set at C<perl Makefile.PL> time. It has the effect of
  1224. setting both INSTALLPRIVLIB and INSTALLSITELIB to that value regardless any
  1225.  
  1226. =item LIBS
  1227.  
  1228. An anonymous array of alternative library
  1229. specifications to be searched for (in order) until
  1230. at least one library is found. E.g.
  1231.  
  1232.   'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"]
  1233.  
  1234. Mind, that any element of the array
  1235. contains a complete set of arguments for the ld
  1236. command. So do not specify
  1237.  
  1238.   'LIBS' => ["-ltcl", "-ltk", "-lX11"]
  1239.  
  1240. See ODBM_File/Makefile.PL for an example, where an array is needed. If
  1241. you specify a scalar as in
  1242.  
  1243.   'LIBS' => "-ltcl -ltk -lX11"
  1244.  
  1245. MakeMaker will turn it into an array with one element.
  1246.  
  1247. =item LINKTYPE
  1248.  
  1249. 'static' or 'dynamic' (default unless usedl=undef in
  1250. config.sh). Should only be used to force static linking (also see
  1251. linkext below).
  1252.  
  1253. =item MAKEAPERL
  1254.  
  1255. Boolean which tells MakeMaker, that it should include the rules to
  1256. make a perl. This is handled automatically as a switch by
  1257. MakeMaker. The user normally does not need it.
  1258.  
  1259. =item MAKEFILE
  1260.  
  1261. The name of the Makefile to be produced.
  1262.  
  1263. =item MAN1PODS
  1264.  
  1265. Hashref of pod-containing files. MakeMaker will default this to all
  1266. EXE_FILES files that include POD directives. The files listed
  1267. here will be converted to man pages and installed as was requested
  1268. at Configure time.
  1269.  
  1270. =item MAN3PODS
  1271.  
  1272. Hashref of .pm and .pod files. MakeMaker will default this to all
  1273.  .pod and any .pm files that include POD directives. The files listed
  1274. here will be converted to man pages and installed as was requested
  1275. at Configure time.
  1276.  
  1277. =item MAP_TARGET
  1278.  
  1279. If it is intended, that a new perl binary be produced, this variable
  1280. may hold a name for that binary. Defaults to perl
  1281.  
  1282. =item MYEXTLIB
  1283.  
  1284. If the extension links to a library that it builds set this to the
  1285. name of the library (see SDBM_File)
  1286.  
  1287. =item NAME
  1288.  
  1289. Perl module name for this extension (DBD::Oracle). This will default
  1290. to the directory name but should be explicitly defined in the
  1291. Makefile.PL.
  1292.  
  1293. =item NEEDS_LINKING
  1294.  
  1295. MakeMaker will figure out, if an extension contains linkable code
  1296. anywhere down the directory tree, and will set this variable
  1297. accordingly, but you can speed it up a very little bit, if you define
  1298. this boolean variable yourself.
  1299.  
  1300. =item NOECHO
  1301.  
  1302. Defaults to C<@>. By setting it to an empty string you can generate a
  1303. Makefile that echos all commands. Mainly used in debugging MakeMaker
  1304. itself.
  1305.  
  1306. =item NORECURS
  1307.  
  1308. Boolean.  Attribute to inhibit descending into subdirectories.
  1309.  
  1310. =item OBJECT
  1311.  
  1312. List of object files, defaults to '$(BASEEXT)$(OBJ_EXT)', but can be a long
  1313. string containing all object files, e.g. "tkpBind.o
  1314. tkpButton.o tkpCanvas.o"
  1315.  
  1316. =item OPTIMIZE
  1317.  
  1318. Defaults to C<-O>. Set it to C<-g> to turn debugging on. The flag is
  1319. passed to subdirectory makes.
  1320.  
  1321. =item PERL
  1322.  
  1323. Perl binary for tasks that can be done by miniperl
  1324.  
  1325. =item PERLMAINCC
  1326.  
  1327. The call to the program that is able to compile perlmain.c. Defaults
  1328. to $(CC).
  1329.  
  1330. =item PERL_ARCHLIB
  1331.  
  1332. Same as above for architecture dependent files
  1333.  
  1334. =item PERL_LIB
  1335.  
  1336. Directory containing the Perl library to use.
  1337.  
  1338. =item PERL_SRC
  1339.  
  1340. Directory containing the Perl source code (use of this should be
  1341. avoided, it may be undefined)
  1342.  
  1343. =item PL_FILES
  1344.  
  1345. Ref to hash of files to be processed as perl programs. MakeMaker
  1346. will default to any found *.PL file (except Makefile.PL) being keys
  1347. and the basename of the file being the value. E.g.
  1348.  
  1349.   {'foobar.PL' => 'foobar'}
  1350.  
  1351. The *.PL files are expected to produce output to the target files
  1352. themselves.
  1353.  
  1354. =item PM
  1355.  
  1356. Hashref of .pm files and *.pl files to be installed.  e.g.
  1357.  
  1358.   {'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm'}
  1359.  
  1360. By default this will include *.pm and *.pl. If a lib directory
  1361. exists and is not listed in DIR (above) then any *.pm and *.pl files
  1362. it contains will also be included by default.  Defining PM in the
  1363. Makefile.PL will override PMLIBDIRS.
  1364.  
  1365. =item PMLIBDIRS
  1366.  
  1367. Ref to array of subdirectories containing library files.  Defaults to
  1368. [ 'lib', $(BASEEXT) ]. The directories will be scanned and any files
  1369. they contain will be installed in the corresponding location in the
  1370. library.  A libscan() method can be used to alter the behaviour.
  1371. Defining PM in the Makefile.PL will override PMLIBDIRS.
  1372.  
  1373. =item PREFIX
  1374.  
  1375. Can be used to set the three INSTALL* attributes in one go (except for
  1376. probably INSTALLMAN1DIR, if it is not below PREFIX according to
  1377. %Config).  They will have PREFIX as a common directory node and will
  1378. branch from that node into lib/, lib/ARCHNAME or whatever Configure
  1379. decided at the build time of your perl (unless you override one of
  1380. them, of course).
  1381.  
  1382. =item PREREQ_PM
  1383.  
  1384. Hashref: Names of modules that need to be available to run this
  1385. extension (e.g. Fcntl for SDBM_File) are the keys of the hash and the
  1386. desired version is the value. If the required version number is 0, we
  1387. only check if any version is installed already.
  1388.  
  1389. =item SKIP
  1390.  
  1391. Arryref. E.g. [qw(name1 name2)] skip (do not write) sections of the
  1392. Makefile. Caution! Do not use the SKIP attribute for the neglectible
  1393. speedup. It may seriously damage the resulting Makefile. Only use it,
  1394. if you really need it.
  1395.  
  1396. =item TYPEMAPS
  1397.  
  1398. Ref to array of typemap file names.  Use this when the typemaps are
  1399. in some directory other than the current directory or when they are
  1400. not named B<typemap>.  The last typemap in the list takes
  1401. precedence.  A typemap in the current directory has highest
  1402. precedence, even if it isn't listed in TYPEMAPS.  The default system
  1403. typemap has lowest precedence.
  1404.  
  1405. =item VERSION
  1406.  
  1407. Your version number for distributing the package.  This defaults to
  1408. 0.1.
  1409.  
  1410. =item VERSION_FROM
  1411.  
  1412. Instead of specifying the VERSION in the Makefile.PL you can let
  1413. MakeMaker parse a file to determine the version number. The parsing
  1414. routine requires that the file named by VERSION_FROM contains one
  1415. single line to compute the version number. The first line in the file
  1416. that contains the regular expression
  1417.  
  1418.     /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/
  1419.  
  1420. will be evaluated with eval() and the value of the named variable
  1421. B<after> the eval() will be assigned to the VERSION attribute of the
  1422. MakeMaker object. The following lines will be parsed o.k.:
  1423.  
  1424.     $VERSION = '1.00';
  1425.     *VERSION = \'1.01';
  1426.     ( $VERSION ) = '$Revision: 1.216 $ ' =~ /\$Revision:\s+([^\s]+)/;
  1427.     $FOO::VERSION = '1.10';
  1428.     *FOO::VERSION = \'1.11';
  1429.  
  1430. but these will fail:
  1431.  
  1432.     my $VERSION = '1.01';
  1433.     local $VERSION = '1.02';
  1434.     local $FOO::VERSION = '1.30';
  1435.  
  1436. The file named in VERSION_FROM is not added as a dependency to
  1437. Makefile. This is not really correct, but it would be a major pain
  1438. during development to have to rewrite the Makefile for any smallish
  1439. change in that file. If you want to make sure that the Makefile
  1440. contains the correct VERSION macro after any change of the file, you
  1441. would have to do something like
  1442.  
  1443.     depend => { Makefile => '$(VERSION_FROM)' }
  1444.  
  1445. See attribute C<depend> below.
  1446.  
  1447. =item XS
  1448.  
  1449. Hashref of .xs files. MakeMaker will default this.  e.g.
  1450.  
  1451.   {'name_of_file.xs' => 'name_of_file.c'}
  1452.  
  1453. The .c files will automatically be included in the list of files
  1454. deleted by a make clean.
  1455.  
  1456. =item XSOPT
  1457.  
  1458. String of options to pass to xsubpp.  This might include C<-C++> or
  1459. C<-extern>.  Do not include typemaps here; the TYPEMAP parameter exists for
  1460. that purpose.
  1461.  
  1462. =item XSPROTOARG
  1463.  
  1464. May be set to an empty string, which is identical to C<-prototypes>, or
  1465. C<-noprototypes>. See the xsubpp documentation for details. MakeMaker
  1466. defaults to the empty string.
  1467.  
  1468. =item XS_VERSION
  1469.  
  1470. Your version number for the .xs file of this package.  This defaults
  1471. to the value of the VERSION attribute.
  1472.  
  1473. =back
  1474.  
  1475. =head2 Additional lowercase attributes
  1476.  
  1477. can be used to pass parameters to the methods which implement that
  1478. part of the Makefile.
  1479.  
  1480. =over 2
  1481.  
  1482. =item clean
  1483.  
  1484.   {FILES => "*.xyz foo"}
  1485.  
  1486. =item depend
  1487.  
  1488.   {ANY_TARGET => ANY_DEPENDECY, ...}
  1489.  
  1490. =item dist
  1491.  
  1492.   {TARFLAGS => 'cvfF', COMPRESS => 'gzip', SUFFIX => 'gz',
  1493.   SHAR => 'shar -m', DIST_CP => 'ln', ZIP => '/bin/zip',
  1494.   ZIPFLAGS => '-rl', DIST_DEFAULT => 'private tardist' }
  1495.  
  1496. If you specify COMPRESS, then SUFFIX should also be altered, as it is
  1497. needed to tell make the target file of the compression. Setting
  1498. DIST_CP to ln can be useful, if you need to preserve the timestamps on
  1499. your files. DIST_CP can take the values 'cp', which copies the file,
  1500. 'ln', which links the file, and 'best' which copies symbolic links and
  1501. links the rest. Default is 'best'.
  1502.  
  1503. =item dynamic_lib
  1504.  
  1505.   {ARMAYBE => 'ar', OTHERLDFLAGS => '...', INST_DYNAMIC_DEP => '...'}
  1506.  
  1507. =item installpm
  1508.  
  1509. Deprecated as of MakeMaker 5.23. See L<ExtUtils::MM_Unix/pm_to_blib>.
  1510.  
  1511. =item linkext
  1512.  
  1513.   {LINKTYPE => 'static', 'dynamic' or ''}
  1514.  
  1515. NB: Extensions that have nothing but *.pm files had to say
  1516.  
  1517.   {LINKTYPE => ''}
  1518.  
  1519. with Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line
  1520. can be deleted safely. MakeMaker recognizes, when there's nothing to
  1521. be linked.
  1522.  
  1523. =item macro
  1524.  
  1525.   {ANY_MACRO => ANY_VALUE, ...}
  1526.  
  1527. =item realclean
  1528.  
  1529.   {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
  1530.  
  1531. =item tool_autosplit
  1532.  
  1533.   {MAXLEN =E<gt> 8}
  1534.  
  1535. =back
  1536.  
  1537. =cut
  1538.  
  1539.  
  1540.  
  1541. =head2 Overriding MakeMaker Methods
  1542.  
  1543. If you cannot achieve the desired Makefile behaviour by specifying
  1544. attributes you may define private subroutines in the Makefile.PL.
  1545. Each subroutines returns the text it wishes to have written to
  1546. the Makefile. To override a section of the Makefile you can
  1547. either say:
  1548.  
  1549.     sub MY::c_o { "new literal text" }
  1550.  
  1551. or you can edit the default by saying something like:
  1552.  
  1553.     sub MY::c_o {
  1554.         package MY;    # so that "SUPER" works right
  1555.         my $inherited = shift->SUPER::c_o(@_);
  1556.         $inherited =~ s/old text/new text/;
  1557.         $inherited;
  1558.     }
  1559.  
  1560. If you running experiments with embedding perl as a library into other
  1561. applications, you might find MakeMaker not sufficient. You'd better
  1562. have a look at ExtUtils::embed which is a collection of utilities for
  1563. embedding.
  1564.  
  1565. If you still need a different solution, try to develop another
  1566. subroutine, that fits your needs and submit the diffs to
  1567. F<perl5-porters@nicoh.com> or F<comp.lang.perl.misc> as appropriate.
  1568.  
  1569. For a complete description of all MakeMaker methods see L<ExtUtils::MM_Unix>.
  1570.  
  1571. Here is a simple example of how to add a new target to the generated
  1572. Makefile:
  1573.  
  1574.     sub MY::postamble {
  1575.     '
  1576.     $(MYEXTLIB): sdbm/Makefile
  1577.         cd sdbm && $(MAKE) all
  1578.     ';
  1579.     }
  1580.  
  1581.  
  1582. =head2 Hintsfile support
  1583.  
  1584. MakeMaker.pm uses the architecture specific information from
  1585. Config.pm. In addition it evaluates architecture specific hints files
  1586. in a C<hints/> directory. The hints files are expected to be named
  1587. like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file
  1588. name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by
  1589. MakeMaker within the WriteMakefile() subroutine, and can be used to
  1590. execute commands as well as to include special variables. The rules
  1591. which hintsfile is chosen are the same as in Configure.
  1592.  
  1593. The hintsfile is eval()ed immediately after the arguments given to
  1594. WriteMakefile are stuffed into a hash reference $self but before this
  1595. reference becomes blessed. So if you want to do the equivalent to
  1596. override or create an attribute you would say something like
  1597.  
  1598.     $self->{LIBS} = ['-ldbm -lucb -lc'];
  1599.  
  1600. =head2 Distribution Support
  1601.  
  1602. For authors of extensions MakeMaker provides several Makefile
  1603. targets. Most of the support comes from the ExtUtils::Manifest module,
  1604. where additional documentation can be found.
  1605.  
  1606. =over 4
  1607.  
  1608. =item    make distcheck
  1609.  
  1610. reports which files are below the build directory but not in the
  1611. MANIFEST file and vice versa. (See ExtUtils::Manifest::fullcheck() for
  1612. details)
  1613.  
  1614. =item    make skipcheck
  1615.  
  1616. reports which files are skipped due to the entries in the
  1617. C<MANIFEST.SKIP> file (See ExtUtils::Manifest::skipcheck() for
  1618. details)
  1619.  
  1620. =item    make distclean
  1621.  
  1622. does a realclean first and then the distcheck. Note that this is not
  1623. needed to build a new distribution as long as you are sure, that the
  1624. MANIFEST file is ok.
  1625.  
  1626. =item    make manifest
  1627.  
  1628. rewrites the MANIFEST file, adding all remaining files found (See
  1629. ExtUtils::Manifest::mkmanifest() for details)
  1630.  
  1631. =item    make distdir
  1632.  
  1633. Copies all the files that are in the MANIFEST file to a newly created
  1634. directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
  1635. exists, it will be removed first.
  1636.  
  1637. =item    make disttest
  1638.  
  1639. Makes a distdir first, and runs a C<perl Makefile.PL>, a make, and
  1640. a make test in that directory.
  1641.  
  1642. =item    make tardist
  1643.  
  1644. First does a distdir. Then a command $(PREOP) which defaults to a null
  1645. command, followed by $(TOUNIX), which defaults to a null command under
  1646. UNIX, and will convert files in distribution directory to UNIX format
  1647. otherwise. Next it runs C<tar> on that directory into a tarfile and
  1648. deletes the directory. Finishes with a command $(POSTOP) which
  1649. defaults to a null command.
  1650.  
  1651. =item    make dist
  1652.  
  1653. Defaults to $(DIST_DEFAULT) which in turn defaults to tardist.
  1654.  
  1655. =item    make uutardist
  1656.  
  1657. Runs a tardist first and uuencodes the tarfile.
  1658.  
  1659. =item    make shdist
  1660.  
  1661. First does a distdir. Then a command $(PREOP) which defaults to a null
  1662. command. Next it runs C<shar> on that directory into a sharfile and
  1663. deletes the intermediate directory again. Finishes with a command
  1664. $(POSTOP) which defaults to a null command.  Note: For shdist to work
  1665. properly a C<shar> program that can handle directories is mandatory.
  1666.  
  1667. =item    make zipdist
  1668.  
  1669. First does a distdir. Then a command $(PREOP) which defaults to a null
  1670. command. Runs C<$(ZIP) $(ZIPFLAGS)> on that directory into a
  1671. zipfile. Then deletes that directory. Finishes with a command
  1672. $(POSTOP) which defaults to a null command.
  1673.  
  1674. =item    make ci
  1675.  
  1676. Does a $(CI) and a $(RCS_LABEL) on all files in the MANIFEST file.
  1677.  
  1678. =back
  1679.  
  1680. Customization of the dist targets can be done by specifying a hash
  1681. reference to the dist attribute of the WriteMakefile call. The
  1682. following parameters are recognized:
  1683.  
  1684.     CI           ('ci -u')
  1685.     COMPRESS     ('compress')
  1686.     POSTOP       ('@ :')
  1687.     PREOP        ('@ :')
  1688.     TO_UNIX      (depends on the system)
  1689.     RCS_LABEL    ('rcs -q -Nv$(VERSION_SYM):')
  1690.     SHAR         ('shar')
  1691.     SUFFIX       ('Z')
  1692.     TAR          ('tar')
  1693.     TARFLAGS     ('cvf')
  1694.     ZIP          ('zip')
  1695.     ZIPFLAGS     ('-r')
  1696.  
  1697. An example:
  1698.  
  1699.     WriteMakefile( 'dist' => { COMPRESS=>"gzip", SUFFIX=>"gz" })
  1700.  
  1701. =head1 SEE ALSO
  1702.  
  1703. ExtUtils::MM_Unix, ExtUtils::Manifest, ExtUtils::testlib,
  1704. ExtUtils::Install, ExtUtils::embed
  1705.  
  1706. =head1 AUTHORS
  1707.  
  1708. Andy Dougherty <F<doughera@lafcol.lafayette.edu>>, Andreas KE<ouml>nig
  1709. <F<A.Koenig@franz.ww.TU-Berlin.DE>>, Tim Bunce <F<Tim.Bunce@ig.co.uk>>.
  1710. VMS support by Charles Bailey <F<bailey@genetics.upenn.edu>>.  OS/2
  1711. support by Ilya Zakharevich <F<ilya@math.ohio-state.edu>>.  Contact the
  1712. makemaker mailing list C<mailto:makemaker@franz.ww.tu-berlin.de>, if
  1713. you have any questions.
  1714.  
  1715. =cut
  1716.